#include "comm.hpp"

void write(int wfd)
{
    char buffer[1024];
    while(true)
    {
        std::cout<<"Please say# ";
        fgets(buffer, sizeof buffer, stdin);
        if(strlen(buffer) > 0) buffer[strlen(buffer)-1] = 0;
        ssize_t n = write(wfd, buffer, strlen(buffer));
        assert(n == strlen(buffer));
        (void)n;
    }

}

int main()
{
    std::cout << "client start! " << std::endl;
    int wfd = open(NAME_PIPE, O_WRONLY);
    std::cout << "client finish! " << std::endl;
    if(wfd < 0) exit(0);
    //write
    write(wfd);

    close(wfd);
    return 0;
}